import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        name: 'newsList',
        redirect: "newsList",
        meta: {
            hidden: true
        }
    },
    {
        path: '/',
        name:'lay',
        component: () => import(/* webpackChunkName: "about" */ '../lay/index.vue'),
        redirect: "newsList",
        children: [
            {
                path: 'newsList',
                name: 'newsList',
                component: () => import(/* webpackChunkName: "about" */ '../views/newsList.vue'),
                meta: {
                    title: "新闻列表",
                    icon:require("../assets/NavBar/list.png"),
                    icon_sel:require("../assets/NavBar/list_sel.png")
                }
            },
            {
                path: 'newsType',
                name: 'newsType',
                component: () => import(/* webpackChunkName: "about" */ '../views/newsType.vue'),
                meta: {
                    title: "新闻分类",
                    icon:require("../assets/NavBar/type.png"),
                    icon_sel:require("../assets/NavBar/type_sel.png")
                }
            },
            {
                path: 'user',
                name: 'user',
                component: () => import(/* webpackChunkName: "about" */ '../views/user.vue'),
                meta: {
                    title: "用户管理",
                    icon:require("../assets/NavBar/user.png"),
                    icon_sel:require("../assets/NavBar/user_sel.png")
                }
            },
        ]
    },
    {
        path: '/login',
        name: 'login',
        component: () => import(/* webpackChunkName: "about" */ '../views/login.vue'),
        meta: {
            title: "登录",
            hidden: true,
        }
    }
]


const router = new VueRouter({
    routes,
    linkActiveClass:"active",
})


router.beforeEach((to, from, next) => {
    window.document.title = to.meta.title;
    next()
})
export default router
